<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title><c:url value="${applicationTitle}"/></title>
	<link rel="stylesheet" href='<c:url value="/resources/css/main.css"/>' type="text/css" />
	<link rel="stylesheet" type="text/css" href='<c:url value="/resources/easyui/themes/default/easyui.css"/>'/>
	<link rel="stylesheet" type="text/css" href='<c:url value="/resources/easyui/themes/icon.css"/>'/>
	<script type="text/javascript" src='<c:url value="/resources/easyui/jquery-1.4.4.min.js"/>'></script>
	<script type="text/javascript" src='<c:url value="/resources/easyui/jquery.easyui.min.js"/>'></script>
	<script type="text/javascript">
	function loadMenu(id) {
		var menus = $("li[name='tm']");
		for(var i = 0; i < menus.length; i++){
			$("#tm_" + i).removeClass("currentlink");
		}
		$("#" + id).addClass("currentlink");
		
		$.ajax({
			url: "<c:url value='/admin/index/menus'/>",
			type: "GET",
			dataType: "json",
			data: ({
				id: id
			}),
			success: function(menus) {
				var sms = $("li[name='sm']");
				for (var i = 0; i < sms.length; i ++) {
					$("#sm_" + i).remove();
				}
				for (var i = 0; i < menus.length; i ++) {
					var clazz = "";
					if (i === 0) {
						clazz = "current";
						mainWindow.location.href = menus[i].url;
					}
					var $li_n = $("<li class=\"" + clazz + "\" "
							+ "name=\"sm\" "
							+ "id=\"sm_" + i + "\" "
							+ "onclick=\"clickSubMenu('sm_" + i + "')\">"
							+ "<a href=\"" + menus[i].url + "\" target=\"mainWindow\">" + menus[i].text + "</a>"
							+ "</li>");
					$("#subMenus").append($li_n);
				}
			}
		});
	}
	
	function clickSubMenu(id) {
		var menus = $("li[name='sm']");
		for(var i = 0; i < menus.length; i++){
			$("#sm_" + i).removeClass("current");
		}
		$("#" + id).addClass("current");
	}
	</script>
</head>
<body id="jive-body" class="easyui-layout">
	<div id="header" region="north" border="false" style="height:135px;">
	    <div id="jive-header">
	        <div id="jive-logo">
	            <img src='<c:url value="/resources/images/login_logo.gif"/>' width="179" height="53" />
	        </div>
	        <div id="jive-userstatus">
	        	User Center 2.0<br/>
	        	 登录账号： <strong><c:out value="${loginAccount.name}"/></strong>（<c:out value="${loginAccount.displayName}"/>）
	        	 - <a href="<c:url value='/logout'/>">注销</a>
	        </div>
	        <div id="jive-nav">
	            <div id="jive-nav-left"></div>
	            <ul id="topMenus">
	            	<c:set var="index" value="0"/>
	            	<c:forEach var="menu" items="${topMenus}">
	            		<c:set var="clazz" value=""/>
	            		<c:if test="${index eq 0}">
	            			<c:set var="clazz" value="currentlink"/>
	            		</c:if>
	            		<li class="${clazz}" name="tm" id="tm_${index}" onclick="loadMenu('tm_${index}')">
	            			<a href="#"><c:out value="${menu.text}"/></a>
	            		</li>
	            		<c:set var="index" value="${index + 1}"/>
	            	</c:forEach>
	            </ul>
	            <div id="jive-nav-right"></div>
	        </div>
	        <div id="jive-subnav">
	            <ul id="subMenus">
	            	<c:set var="index" value="0"/>
	            	<c:forEach var="menu" items="${subMenus}">
	            		<c:set var="clazz" value=""/>
	            		<c:if test="${index eq 0}">
	            			<c:set var="clazz" value="current"/>
	            		</c:if>
	            		<li class="${clazz}" name="sm" id="sm_${index}" onclick="clickSubMenu('sm_${index}')">
	            			<a href="${menu.url}" target="mainWindow"><c:out value="${menu.text}"/></a>
	            		</li>
	            		<c:set var="index" value="${index + 1}"/>
	            	</c:forEach>
	            </ul>
	        </div>
	    </div>
	</div>
	<div region="center" border="false" style="overflow-x:hidden;overflow-y:hidden">
		<c:set var="indexPage" value="about:blank"/>
		<c:if test="${fn:length(subMenus) gt 0}">
			<c:set var="indexPage" value="${subMenus[0].url}"/>
		</c:if>
		<iframe name="mainWindow" frameborder="0" border="0" 
			marginWidth="0" marginHeight="0" src="${indexPage}" 
			style="width:100%;height:100%;border:0px;background-color:white; "></iframe>
	</div>
</body>
</html>